package com.jvm123.demo;

import com.jvm123.minio.service.client.MinioClientProvider;
import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@SpringBootApplication
public class DemoMinioApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoMinioApplication.class, args);
    }

    @Bean
    MinioClientProvider minClient() {
        return (endpoint, accessKey, secretKey) -> {
            try {
                return new MinioClient("http://petdy.cn:9000", "admin", "1234567890");
            } catch (InvalidEndpointException | InvalidPortException e) {
                e.printStackTrace();
                return null;
            }
        };
    }
}
